﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace AntikCompta.Data
{
    [XmlRoot("Vendeur")]
    [XmlInclude(typeof(VendeurParticulier)), XmlInclude(typeof(VendeurMarchandHt))]
    public abstract class Vendeur
    {
        protected String mNom;
        protected float mTva;

        [XmlIgnore]
        public String Nom
        {
            get { return mNom; }
            set { mNom = value; }
        }

        internal float Tva
        {
            get { return mTva; }
            set { mTva = value; }
        }

        internal abstract float GetPrixAchat(float aPrixAchat);
    }

    public class VendeurParticulier : Vendeur
    {
        public VendeurParticulier()
        {
            mNom = "Particulier";
            mTva = 19.6F;
        }

        internal override float GetPrixAchat(float aPrixAchat)
        {
            return aPrixAchat;
        }
    }

    public class VendeurMarchandHt : Vendeur
    {
        public VendeurMarchandHt()
        {
            mNom = "Marchand (HT)";
            mTva = 19.6F;
        }

        internal override float GetPrixAchat(float aPrixAchat)
        {
            return (float)Math.Round(aPrixAchat/(1+(mTva/100)), 2);
        }
    }
}
